package com.haipumi.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.web.context.support.WebApplicationObjectSupport;

import com.haipumi.beans.haipumi_skin;
import com.haipumi.beans.haipumi_taskType;
import com.haipumi.biz.IBackSkinBiz;
import com.haipumi.biz.TaskTypeBiz;
import com.haipumi.biz.impl.TaskTypeBizImpl;
import com.haipumi.utils.CommonData;

public class TaskTypeListener extends WebApplicationObjectSupport implements ApplicationListener<ContextRefreshedEvent> {
	
	@Autowired
	private TaskTypeBiz taskTypeBiz;
	
	private ServletContext servletContext;
	
    @Override
	protected void initServletContext(ServletContext servletContext) {
		this.servletContext=servletContext;
	}
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ev) {
    	//访问数据库,得到所有的商品存到application中
		List<haipumi_taskType> list=taskTypeBiz.findAllTaskType(null);
		//如何取出application
		servletContext.setAttribute(CommonData.APPLICATIONTASKTYPE, list);
    }
 
}
